import express from 'express'
import chalk from 'chalk'
const router = express.Router()

router.get('*',(req, res, next)=>{ //处理不匹配的get请求
    console.log(
        chalk.red(`Can not resolve the get url ${req.baseUrl}`)
    )
    res.status(500).json({ ERROR: 'ERROR GET REQUEST!' })
})

router.post('*', (req, res, next) => { //处理不匹配的post请求
    console.log(
        chalk.red(`Can not resolve the post url ${req.baseUrl}`)
    )
    res.status(500).send({ ERROR: 'ERROR POST REQUEST!' })
})

router.delete('*', (req, res, next) => { //处理不匹配的delete请求
    console.log(
        chalk.red(`Can not resolve the delete url ${req.baseUrl}`)
    )
    res.status(500).json({ ERROR: 'ERROR DELETE REQUEST!' })
})

router.put('*', (req, res, next) => { //处理不匹配的put请求
    console.log(
        chalk.red(`Can not resolve the put url ${req.baseUrl}`)
    )
    res.status(500).send({ ERROR: 'ERROR PUT REQUEST!' })
})

export default router